﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XNAGameFeatures.Widget
{
    public class BasicButton : Button
    {
        private readonly String _text;
        private Vector2 _pos;

        public BasicButton(String text, Vector2 pos)
        {
            _text = text;
            _pos = pos;
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();
            SpriteBatch.DrawString(ScreenManager.FontManager.Fonts["Default"], _text, _pos, Color.Black);
            SpriteBatch.End();
        }

        public override void LoadContent()
        {
            int width = (int)ScreenManager.FontManager.Fonts["Default"].MeasureString(_text).X;
            int height = (int)ScreenManager.FontManager.Fonts["Default"].MeasureString(_text).Y;

            Area = new Rectangle((int)_pos.X, (int)_pos.Y, width, height);
        }

        public override void UnloadContent()
        {
        }

        public override void Update(GameTime gameTime)
        {
        }
    }
}
